#FLAGS += $(INC)
#FLAGS += @$(TOPDIR)/core/config/def.mk

ALL_INC_PATHS   = $(patsubst %,-I%,$(SDK_INC) $(EXTRA_INC))

FLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-unused-pointer-sign -Wno-sign-compare -Wno-incompatible-pointer-types -Wno-pointer-sign
FLAGS += -fdata-sections -ffunction-sections
FLAGS += -Os -DNDEBUG
FLAGS += -mcpu=cortex-r5
FLAGS += -mthumb
FLAGS += -mthumb-interwork
FLAGS += -mlong-calls
FLAGS += -mfloat-abi=soft
FLAGS += -mno-unaligned-access
FLAGS += -Wno-error=format=
FLAGS += -Wno-error=type-limits
FLAGS += -Wno-error=enum-conversion


ifeq (x$(USE_LIBC),xyes)
ifeq (x$(USE_NANO),xyes)
FLAGS += -specs=nano.specs #-u _scanf_float -u _printf_float
endif
FLAGS += -specs=nosys.specs
else
FLAGS += -nostartfiles -nodefaultlibs
endif
FLAGS += -specs=$(TOPDIR)/core/config/sdk.specs

#CFLAGS += $(ALL_INC_PATHS) $(FLAGS) -std=c99
CFLAGS += $(ALL_INC_PATHS) $(FLAGS) -std=gnu99
CXXFLAGS += $(ALL_INC_PATHS) $(FLAGS) -std=c++11
LDFLAGS += $(FLAGS) -Wl,--gc-sections

LDFLAGS += -Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=printf -Wl,--wrap=snprintf -Wl,--wrap=sprintf -Wl,--wrap=vsnprintf -Wl,--wrap=vsprintf -Wl,--wrap=sscanf

LINK_SCRIPT = $(TOPDIR)/core/config/app.ld
ifneq (x$(USE_LIBC),xyes)
LINK_SCRIPT = $(TOPDIR)/core/config/app_sdkonly.ld
endif

ifeq (x$(CHIP),x1602c)
LINK_SCRIPT = $(TOPDIR)/core/config/app_1602c.ld
else ifeq (x$(CHIP),x1602s)
LINK_SCRIPT = $(TOPDIR)/core/config/app_1602s.ld
else ifeq (x$(CHIP),x1606l)
LINK_SCRIPT = $(TOPDIR)/core/config/app_1606l.ld
else ifeq (x$(CHIP),x1606c)
LINK_SCRIPT = $(TOPDIR)/core/config/app_1606c.ld
else ifeq (x$(CHIP),x1606s)
LINK_SCRIPT = $(TOPDIR)/core/config/app_1606s.ld
endif
